﻿using Engine;
using Engine.Graphics;
using Game;

namespace SAGhoul
{
	public class ComponentTrophyModel : ComponentModel
	{
        public ModelBone m_chunkBone;
        public override void Animate()
        {
            SetBoneTransform(Model.RootBone.Index, m_componentFrame.Matrix);
            var time = Time.FrameStartTime;
            if(m_chunkBone != null)
			{
                float rotationX = (float)(time * 0.5f) % (2f * MathUtils.PI);
                float rotationY = (float)(time * 0.5f) % (2f * MathUtils.PI);
                float offsetY = (float)MathUtils.Sin(time) * 0.12f;
                SetBoneTransform(m_chunkBone.Index, Matrix.CreateFromYawPitchRoll(rotationY, rotationX, 0) * Matrix.CreateTranslation(0, 0, offsetY));
            }
            base.Animate();
        }

        public override void SetModel(Model model)
        {
            base.SetModel(model);
            if (Model != null)
            {
                m_chunkBone = Model.FindBone("Chunk");
            }
        }

    }
}
